package com.learn.sb.sblearnshardingjdbc.controller;

import com.learn.sb.sblearnshardingjdbc.pojo.*;
import com.learn.sb.sblearnshardingjdbc.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/mybatis")
public class MybatisController {

	@Autowired
	private UserService userService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private DictService dictService;
	@Autowired
	private RoleService roleService;
	@Autowired
	private LogassetService logassetService;

	@RequestMapping("/getUser")
	@ResponseBody
	public User getUser(Integer id) {
		return userService.getUser(id);
	}

	@RequestMapping("/getOrder")
	@ResponseBody
	public Order getOrder(Integer orderId) {
		return orderService.getOrder(orderId);
	}

	@RequestMapping("/getOrderByUserId")
	@ResponseBody
	public Order getOrderByUserId(Integer userId, Integer orderId) {
		return orderService.getOrderByUserId(userId, orderId);
	}

	@RequestMapping("/getDictByKey")
	@ResponseBody
	public Dict getDictByKey(String key) {
		return dictService.getByKey(key);
	}

	@RequestMapping("/getByRoleid")
	@ResponseBody
	public Role getByRoleid(Integer roleId) {
		return roleService.getByRoleid(roleId);
	}

	@RequestMapping("/getByBizdate")
	@ResponseBody
	public Logasset getByBizdate(Integer bizdate) {
		return logassetService.getByBizdate(bizdate);
	}

	@RequestMapping("/listByBetween")
	@ResponseBody
	public List<Logasset> listByBetween(Integer beginDate, Integer endDate) {
		return logassetService.listByBetween(beginDate, endDate);
	}

}
